<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta content="telephone=no" name="format-detection" />
    <!-- 留作将来统一添加 -->
    <TEMPLATE>${TEMPLATE}</TEMPLATE>
    <title>模板html</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css">
    <link rel="stylesheet" type="text/css" href="../../css/index.css">
    <link rel="stylesheet" type="text/css" href="../../css/data-flex.min.css">
    <style type="text/css">
        body {
            background: rgba(255, 255, 255, 1);
        }

        .row {
            margin: 15px;
        }

        .avatar {
            width: 32px;
            height: 32px;
            margin-right: 10px;
        }

        .name {
            font-size: 15px;
            font-weight: 400;
            color: rgba(25, 25, 25, 1);
        }

        .time {
            font-size: 12px;
            font-weight: 400;
            color: rgba(191, 191, 191, 1);
        }

        .content {
            font-size: 15px;
            font-weight: 400;
            color: rgba(25, 25, 25, 1);
            line-height: 25px;
        }

        .image {
            width: 100%;
            border-radius: 8px;
            overflow: hidden;
        }

        .btn {
            position: fixed;
            bottom: 0;
            width: 100%;
            height: 50px;
            background: rgba(226, 83, 83, 1);
            font-size: 16px;
            font-weight: 600;
            color: rgba(255, 255, 255, 1);
            line-height: 22px;
        }

        .btn-occupy {
            height: 50px;
        }
    </style>
</head>

<body>
    <div class="vueApp" v-cloak>
        <div class="row" data-flex>
            <div class="avatar">
                <img :src="icon" alt="">
            </div>
            <div data-flex-box="1">
                <div class="name">{{ nickname }}</div>
                <div class="time">{{ transformDate }}</div>
            </div>
        </div>
        <div class="row" v-if="content">
            <div class="content">
                {{ content }}
            </div>
        </div>
        <div class="row" v-for="item in url">
            <div class="image" v-if="item">
                <img :src="item" alt="">
            </div>
        </div>
        <!-- 按钮占位 -->
        <div class="btn-occupy" v-if="userType == 2"></div>
        <div class="btn" v-if="userType == 2" data-flex="main:center cross:center" @click="fnOpenAlert({alertType:'9',alertConfirmFn:'deleteNoticeFn'})">
            删除公告
        </div>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/service/service-tool.js"></script>
<script type="text/javascript" src="../../script/service/service-app.js"></script>
<script type="text/javascript" src="../../script/service/service-user.js"></script>
<script type="text/javascript" src="../../script/service/service-logic.js"></script>
<script type="text/javascript" src="../../script/jquery.min.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript">
    // html 的引号一律为双引号(""),js 为单引号('')
    var USER, $S, vm, param;
    apiready = function () {
        $S = SERVICE();
        USER = USER();
        console.log(JSON.stringify(api.pageParam) + '=====pageParam');
        param = api.pageParam;
        fnInit();
    };
    // 初始化
    function fnInit() {
        vm = new Vue({
            el: '.vueApp',
            data: {
                pageNo: 1,
                pageSize: 1000,
                userType: getUserType(),
                nickname: '',
                icon: '',
                content: '',
                url: [],
                createDate: ''
            },
            computed: {
                transformDate: function () {
                    return formateTime(this.createDate, 'order_data');
                }
            }
        });
        getPageData();
    }

    // 获取页面数据
    function getPageData() {
        var url = 'clsClass/findNoticeDetail';
        var params = {
            "id": param.noticeId
        };
        var callback = function (data) {
            vm.nickname = data.nickName;
            vm.icon = data.icon;
            vm.content = data.content;
            vm.createDate = data.createDate;
            vm.url = data.url.split(',');
            // status 为200时,只返回data
        };
        var error = function (res) {
            // status 不是200时,全部返回
            api.refreshHeaderLoadDone();
        };
        POST(url, params, callback, error);
    }

    // 删除公告
    function deleteNoticeFn() {
        var url = 'common/deleteById';
        var params = {
            "entityName": 'clsClassesNotice',
            "id": param.noticeId
        };
        var callback = function (data) {
            fnToast('删除成功');
            api.sendEvent({
                name: 'classNoticeDelete'
            })
            api.closeWin();
            // status 为200时,只返回data
        };
        var error = function (res) {
            // status 不是200时,全部返回
            api.refreshHeaderLoadDone();
        };
        POST(url, params, callback, error);
    }
</script>

</html>